﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer.Security;
using Common;
namespace DataAccessLayer.DAL
{
    public class UserSettingDAL
    {
        /// <summary>
        /// Lay thong tin cua mot UserReference bang username
        /// </summary>
        /// <param name="username">Username of user store in DB</param>
        /// <returns>Appropriate user if exists, NULL if not.</returns>
        public static UserSetting GetUserSettinglByIDUser(int idUser)
        {
            using (var context = new ReverseAuctionEntities())
            {
                return context.UserSettings.SingleOrDefault(u => u.UserID == idUser);
            }
           
        }
        /// <summary>
        /// Cap nhat thong tin mot UserSetting
        /// </summary>
        /// <param name="user">UserSetting to update</param>
        public static void UpdateUserSetting(UserSetting userSetting)
        {
            using (var context = new ReverseAuctionEntities())
            {
                context.UserSettings.Attach(userSetting);
                context.ObjectStateManager.ChangeObjectState(userSetting, System.Data.EntityState.Modified);
                context.SaveChanges();
            }
        }
    }
}
